package com.matrix.socket;

import java.net.ServerSocket;
import java.net.Socket;

public class Server {
    public static void main(String[] args) throws Exception {
        ServerSocket ss = new ServerSocket(9099);
        System.out.println("服务器已经启动，等待客服端连接...");
        int count=0;
        while (true) {
            Socket accept = ss.accept();
            System.out.println("这是第几" +(count++)+"个客户：");
            System.out.println("客户端主机名：" + accept.getInetAddress().getHostName() +"," + accept.getInetAddress().getCanonicalHostName());
            System.out.println("客户端地址：" + accept.getInetAddress().getHostAddress());
            ServerThread st = new ServerThread(accept);
            st.start();

        }


    }
}
